package Singleton;

/**
 * 双重校验锁的单例模式
 */
public class SingletonExample3 {
    private volatile static SingletonExample3 instance ;

    private SingletonExample3(){}

    private static SingletonExample3 getInstance(){
        if (instance == null){ // 第一重校验
            synchronized (SingletonExample3.class){
                if (instance == null){
                    instance = new SingletonExample3();
                }
            }
        }
        return instance;
    }
}
